|
|
|
|
|
|
|
Guidelines for Planning Cyclical and Ad Hoc Reporting Uses |
|
|
|
|
|
|
|
|
Having users print built-in, canned reports immediately upon clicking a Print button is easy, especially when you design the reports in Access or Crystal Reports. However, giving the user the ability to schedule the printing of reports and customizing the kind of information printed from a report is more difficult. |
|
|
|
|
|
|
|
|
Scheduling reports to be printed once at some future date and time or cyclically is not as involved as giving users ad hoc reporting abilities. It involves capturing the date and time from the user, saving it to a database, the Registry, or a text file, and continuously checking for the designated date and/or time. After the date and time have arrived, print the report. For this task, it is good to have a controller class called ReportScheduler and a form controlled by this class that has a timer control. The ReportScheduler class would have the following properties: |
|
|
|
|
|
|
|
|
Private mReportDate As Date
Private mReportTime As Date
Private theForm As New frmScheduledReports
Private WithEvents theTimer As Timer |
|
|
|
|
|
|
|
|
and the following methods: |
|
|
|
|
|
|
|
|
Public Sub scheduleReport(argReportName As String, _ argReportDate As Date, argReportTime As Date)
Public Sub cancelReport(argReportID As Long)
Private Sub isTimeToPrint(argReportDate As Date, _ argReportTime As Date)
Private Sub printReport |
|
|
|
|
|
|
|
|
The private properties, ReportDate and ReportTime, respectively, contain the date and time the report is to be printed. The property, theForm, is a reference to the form, frmScheduledReports, which has a Timer control, a list box, or grid control to inform the user of the scheduled reports, and a command button, cmdCancelReport, that allows a user to cancel a scheduled report. The user would have to select a report first. The property, theTimer, is a reference to the Timer control on the form. The WithEvents keyword allows you to maintain the code for the timer's single event, Timer, within the class instead of in the form. This way, you can implement the same timer code from one class for many scheduling-oriented forms. In the ReportScheduler class, in its object list, you will see the the Timer object along with |
|
|
|
|
|
|
|
|
Private Sub theTimer_Timer()
End Sub |
|
|
|
|
|